package com.itheima.doudizhu1;

import java.util.ArrayList;
import java.util.Collections;

public class PokerGame {
    static ArrayList<String> list = new ArrayList<>();

    //准牌阶段
    static {
        //♠ ♥ ♣ ♦
        //2 3 4 5 6 7 8 9 10 J Q K A 2
        String[] color = {"♠", "♥", "♣", "♦"};
        String[] number = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        //创建结合

        for (String c : color) {
            for (String n : number) {
                list.add(c + n);
            }
        }
        //添加大小王
        list.add("大王");
        list.add("小王");
    }

    PokerGame() {

        //2.洗牌
        Collections.shuffle(list);
        //3.发牌
        ArrayList<String> dipai = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            //i为索引
            String puke = list.get(i);
            if (i <= 2) {
                dipai.add(puke);
                continue;
            }

            if (i % 3 == 0) {
                //发给第一个人
                player1.add(puke);
            } else if (i % 3 == 1) {
                //发给第二个人
                player2.add(puke);
            } else {
                player3.add(puke);
            }
        }
        //4.看牌
        LookPoker("底牌",dipai);
        LookPoker("张三",player1);
        LookPoker("大帅哥",player2);
        LookPoker("李四",player3);
    }

    //看牌抽象成方法
    public void LookPoker(String name, ArrayList<String> list) {
        System.out.println(name + ":");
        for (String poker : list) {
            System.out.print(poker + " ");
        }
        //换行
        System.out.println();
    }
}
